<template>
  <div class="register">
    <auth-form
      btnColor="#07c160"
      title="面经注册"
      linkName="有账号,去登录"
      linkPath="/login"
      @onSubmit="onSubmit"
    ></auth-form>
  </div>
</template>

<script>
import AuthForm from "@/components/AuthForm.vue";
import myAxios from "@/utils/httpUtil";
import { Toast } from "vant";

export default {
  name: "RegisterPage",
  components: {
    AuthForm,
  },
  methods: {
    onSubmit(values) {
      console.log(values);

      myAxios
        .post("/h5/user/register", {
          username: values.username,
          password: values.password,
        })
        .then((res) => {
          console.log(res.data);
          if (res.data.code === 10000) {
            Toast("注册成功");
            this.$router.replace("/login");
          }
        })
        .catch((error) => {
          Toast(error.response.data.message);
          console.log(error);
        });
    },
  },
};
</script>

<style></style>
